package com.example.mobile2032021606170hsy0421;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import java.util.List;
import java.util.concurrent.Callable;

public class CarRViewAdapter extends RecyclerView.Adapter<CarRViewAdapter.ViewHold>{
    List<Car>list;
    public  CarRViewAdapter(List<Car> list){
        this.list = list;
    }
    static class ViewHold extends RecyclerView.ViewHolder {
        TextView tvProcess, tvPart;

        public ViewHold(@NonNull View itemView) {
            super(itemView);
            this.tvProcess = itemView.findViewById(R.id.tvItemprocess);
            this.tvPart = itemView.findViewById(R.id.tvItempart);
        }
    }
    @NonNull
    @Override
    public ViewHold onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_rv_main_car,null);
        ViewHold viewHold = new ViewHold(view);
        return viewHold;
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHold holder, int position) {
        Car car =list.get(position);
        holder.tvProcess.setText(car.getProcess());
        holder.tvPart.setText(car.getPart());
    }

    @Override
    public int getItemCount() {
        return list.size();
    }


}
